<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Summernote</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/summernote@0.8.20/dist/summernote-bs5.min.css" rel="stylesheet">
    <style>
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
            margin: 0;
            padding: 24px;
            background-color: #f5f5f5;
        }
        .container {
            max-width: 1200px;
            margin: 0 auto;
            background: white;
            padding: 24px;
            border-radius: 8px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        }
        .title {
            font-size: 24px;
            font-weight: 600;
            margin-bottom: 8px;
            color: #262626;
        }
        .description {
            color: #595959;
            margin-bottom: 24px;
            line-height: 1.6;
        }
        .btn-custom {
            background: #1890ff;
            color: white;
            border: none;
            padding: 8px 16px;
            border-radius: 6px;
            cursor: pointer;
            font-size: 14px;
            margin-right: 8px;
            margin-top: 16px;
        }
        .btn-custom:hover {
            background: #40a9ff;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1 class="title">Summernote 富文本编辑器</h1>
        <p class="description">
            Summernote 是一个基于 Bootstrap 的简单灵活的富文本编辑器。
        </p>
        
        <div id="summernote">
            <p>这是 Summernote 编辑器的初始内容。</p>
            <p>Summernote 特点：</p>
            <ul>
                <li>基于 Bootstrap 设计</li>
                <li>支持图片拖拽上传</li>
                <li>丰富的插件系统</li>
                <li>响应式设计</li>
                <li>多语言支持</li>
            </ul>
            <p>你可以尝试各种格式化功能！</p>
        </div>
        
        <button class="btn-custom" onclick="getContent()">获取内容</button>
        <button class="btn-custom" onclick="setContent()">设置内容</button>
        <button class="btn-custom" onclick="insertText()">插入文本</button>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/summernote@0.8.20/dist/summernote-bs5.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/summernote@0.8.20/dist/lang/summernote-zh-CN.min.js"></script>
    
    <script>
        $(document).ready(function() {
            $('#summernote').summernote({
                height: 400,
                lang: 'zh-CN',
                toolbar: [
                    ['style', ['style']],
                    ['font', ['bold', 'underline', 'clear']],
                    ['fontname', ['fontname']],
                    ['color', ['color']],
                    ['para', ['ul', 'ol', 'paragraph']],
                    ['table', ['table']],
                    ['insert', ['link', 'picture', 'video']],
                    ['view', ['fullscreen', 'codeview', 'help']]
                ],
                placeholder: '请输入内容...',
                tabsize: 2,
                callbacks: {
                    onChange: function(contents, $editable) {
                        console.log('内容已改变:', contents);
                    }
                }
            });
        });

        function getContent() {
            var content = $('#summernote').summernote('code');
            console.log(content);
            alert('内容已输出到控制台');
        }

        function setContent() {
            $('#summernote').summernote('code', '<p>这是通过 JavaScript 设置的新内容</p><p>包含<strong>粗体</strong>和<em>斜体</em>文本。</p>');
        }

        function insertText() {
            $('#summernote').summernote('insertText', '这是插入的文本 ');
        }
    </script>
</body>
</html>